<!DOCTYPE html>
<html>
<head>
	<meta name="author" content="Yeeku.H.Lee(CrazyIt.org)" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title> 使用WebSocket通信 </title>
	<script type="text/javascript">
		// 创建Web Socket对象
		var webSocket = new WebSocket("ws://127.0.0.1:30000");
		webSocket.onopen = function()
		{
			// 为onmessage事件绑定监听器，接收消息
			webSocket.onmessage= function(event)
			{
				// 接收、并显示消息
				document.getElementById('show').innerHTML 
					+= event.data + "<br/>";
			}
		};
		var sendMsg = function(val)
		{
			var inputElement = document.getElementById('msg');
			// 发送消息
			webSocket.send(inputElement.value);
			// 清空单行文本框
			inputElement.value = "";
		}
	</script>
</head>
<body>
<div style="width:600px;height:240px;
	overflow-y:auto;border:1px solid #333;" id="show"></div>
<input type="text" size="80" id="msg" name="msg"/>
<input type="button" value="发送" onclick="sendMsg();"/>
</body>
</html>
